<?php

namespace App\Admin\Controllers;

use App\Http\Controllers\Controller;
use App\Logic\Admin\Service\UserService;
use App\Models\Admin\Image\Series;
use App\Models\Admin\User\Author;
use App\Models\Admin\User\User;
use Encore\Admin\Layout\Content;
use Encore\Admin\Layout\Row;
use Encore\Admin\Widgets\Box;

class HomeController extends Controller
{
    public function index(Content $content): Content
    {
        return $content
            ->header('Echarts')
            ->title("数据总览")
            ->row(function (Row $row) {
                $row->column(6, new Box('注册用户', view('admin.user', [
                    "man" => User::getCurrentWeekRegister(1),
                    "woman" => User::getCurrentWeekRegister(2),
                    "noknow" => User::getCurrentWeekRegister(),
                ])));
                $row->column(6, new Box('认证作者', view('admin.author', [
                    "man" => Author::getCurrentWeekRegister(1),
                    "woman" => Author::getCurrentWeekRegister(2),
                    "noknow" => Author::getCurrentWeekRegister(),
                ])));
            })->row(function (Row $row) {
                $series = (new Series())->homeData();
                $row->column(6, new Box('壁纸系列', view('admin.category', [
                    "total" => $series,
                    'top' => count($series) >= 3 ? array_slice($series, 0, 3) : $series,
                    "title" => array_column($series, "name")
                ])));
                $row->column(6, new Box('资源下载走势图', view('admin.download', [
                    "man" => [10, 3333, 333, 11, 12, 12, 9],
                    "woman" => [102, 11, 132, 211, 12, 212, 9],
                    "noknow" => [12, 81, 102, 53, 3, 82, 20],
                ])));
            });
    }
}
